package com.example.pro1;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;

//篮球积分程序1.0
public class MainActivity extends AppCompatActivity{
    ImageButton img1, img2;
    int count = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    /*
    public void cnt(View v) {
        img1 = findViewById(R.id.image1);
        img2 = findViewById(R.id.image2);
        if(count%2 == 0) {
            img1.setVisibility(View.INVISIBLE);
            img2.setVisibility(View.VISIBLE);
        }
        else {
            img1.setVisibility(View.VISIBLE);
            img2.setVisibility(View.INVISIBLE);
        }
        count ++;
    }
    */

    public void btu(View v) {
        int id = v.getId();
        Button btu = findViewById(id);
        TextView curScore = findViewById(R.id.score);

        String op = btu.getText().toString();
        if(op.length() > 3) {
            curScore.setText("0");
        }
        else {
            int score = Integer.parseInt(curScore.getText().toString());
            score += (op.charAt(1) - '0');
            curScore.setText(""+score);
        }
    }
    /*
    public void btu1(View v) {

        TextView scoreCur = findViewById(R.id.score);
        int score = Integer.parseInt(scoreCur.getText().toString());
        score += 3;
        scoreCur.setText(""+score);

    }

    public void btuRes(View v) {

        TextView scoreCur = findViewById(R.id.score);
        scoreCur.setText("0");
    }*/
}